package com.natsumehill.ls.dao;

import com.alipay.sofa.runtime.api.annotation.SofaService;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.natsumehill.ls.po.UserPo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

@Repository
@SofaService
public class SqlMapUserDao extends SqlMapClientDaoSupport implements UserDao {

    @Autowired
    public void init(SqlMapClient sqlMapClient){
        super.setSqlMapClient(sqlMapClient);
    }
    @Override
    public UserPo getUserByName(String name) {
        return (UserPo) getSqlMapClientTemplate().queryForObject("getUserByName", name);
    }

    @Override
    public void insertUser(UserPo userPo) {
        getSqlMapClientTemplate().update("insertUser", userPo);
    }
}
